﻿/* power by 风情剑客 www.uu6c.com 2013.11.20*/
/*banner*/
$(function starts(){
  var timer=5000;
  var showtime = 800;
  var showbox1 = $("#banner_show1");
  var inbox1 = $("#banner_show1 .bannger_inbox");
  var movelist1 = $("#banner_show1 #yq_banner_list1");
  var showbox2 = $("#banner_hide2");
  var inbox2 = $("#banner_hide2 .bannger_inbox");
  var movelist2 = $("#banner_hide2 #yq_banner_list2");
  var showbox3 = $("#banner_hide3");
  var inbox3 = $("#banner_hide3 .bannger_inbox");
  var movelist3 = $("#banner_hide3 #yq_banner_list3");
  var showbox4 = $("#banner_hide4");
  var inbox4 = $("#banner_hide4 .bannger_inbox");
  var movelist4 = $("#banner_hide4 #yq_banner_list4");
  var showbox5 = $("#banner_hide5");
  var inbox5 = $("#banner_hide5 .bannger_inbox");
  var movelist5 = $("#banner_hide5 #yq_banner_list5");
  var showbox6 = $("#banner_hide6");
  var inbox6 = $("#banner_hide6 .bannger_inbox");
  var movelist6 = $("#banner_hide6 #yq_banner_list6");
  var s1,s2,s3,s4,s5,s6;var play1,play2,play3,play4,play5,play6;
  var b1 = 0;
  var b2 = 0;
  var b3 = 0;
  var b4 = 0;
  var b5 = 0;
  var b6 = 0;
  var size1 =inbox1.size();
  var size2 =inbox2.size();
  var size3 =inbox3.size();
  var size4 =inbox4.size();
  var size5 =inbox5.size();
  var size6 =inbox6.size();
  function move1(){
    b1++;
    if(b1>size1-1){
      b1=0;
    }
    if(size1>1){
        inbox1.each(function(e){
          inbox1.eq(e).hide(0);
          $("#banner_show1 #banner_magbox1"+e).hide();
          movelist1.find("a").eq(e).removeClass("hover");
          if(e == b1){
            inbox1.eq(b1).fadeIn(showtime);
            $("#banner_show1 #banner_magbox1"+b1).show();
            movelist1.find("a").eq(b1).addClass("hover");
          }
        });
    }    
  }
  function move2(){
    if(size2>1){
        b2++;
        if(b2>size2-1){
          b2=0;
        }    
        inbox2.each(function(e){
          inbox2.eq(e).hide(0);
          $("#banner_hide2 #banner_magbox2"+e).hide();
          movelist2.find("a").eq(e).removeClass("hover");
          if(e == b2){
            inbox2.eq(b2).fadeIn(showtime);
            $("#banner_hide2 #banner_magbox2"+b2).show();
            movelist2.find("a").eq(b2).addClass("hover");
          }
        });
    }
  }
  function move3(){
    if(size3>1){
        b3++;
        if(b3>size3-1){
          b3=0;
        }    
        inbox3.each(function(e){
          inbox3.eq(e).hide(0);
          $("#banner_hide3 #banner_magbox3"+e).hide();
          movelist3.find("a").eq(e).removeClass("hover");
          if(e == b3){
            inbox3.eq(b3).fadeIn(showtime);
            $("#banner_hide3 #banner_magbox3"+b3).show();
            movelist3.find("a").eq(b3).addClass("hover");
          }
        });
    }
  }
  function move4(){
    if(size4>1){
        b4++;
        if(b4>size4-1){
          b4=0;
        }
        inbox4.each(function(e){
          inbox4.eq(e).hide(0);
          $("#banner_hide4 #banner_magbox4"+e).hide();
          movelist4.find("a").eq(e).removeClass("hover");
          if(e == b4){
            inbox4.eq(b4).fadeIn(showtime);
            $("#banner_hide4 #banner_magbox4"+b4).show();
            movelist4.find("a").eq(b4).addClass("hover");
          }
        });
    }
  }
  function move5(){
    if(size5>1){
        b5++;
        if(b5>size5-1){
          b5=0;
        }    
        inbox5.each(function(e){
          inbox5.eq(e).hide(0);
          $("#banner_hide5 #banner_magbox5"+e).hide();
          movelist5.find("a").eq(e).removeClass("hover");
          if(e == b5){
            inbox5.eq(b5).fadeIn(showtime);
            $("#banner_hide5 #banner_magbox5"+b5).show();
            movelist5.find("a").eq(b5).addClass("hover");
          }
        });
    }
  }
  function move6(){
    if(size6>1){
        b6++;
        if(b6>size6-1){
          b6=0;
        }
        inbox6.each(function(e){
          inbox6.eq(e).hide(0);
          $("#banner_hide6 #banner_magbox6"+e).hide();
          movelist6.find("a").eq(e).removeClass("hover");
          if(e == b6){
            inbox6.eq(b6).fadeIn(showtime);
            $("#banner_hide6 #banner_magbox6"+b6).show();
            movelist6.find("a").eq(b6).addClass("hover");
          }
        });
    }
  }
  function move_timer_pd(nums){
    var djpd=$("#hidclick").val();
    if(djpd==nums){
        if(nums==1){
            move1();
        }
        else{
            clearInterval(s1);
        }
        if(nums==2){
            move2();
        }
        else{
            clearInterval(s2);
        }
        if(nums==3){
            move3();
        }
        else{
            clearInterval(s3);
        }
        if(nums==4){
            move4();
        }
        else{
            clearInterval(s4);
        }
        if(nums==5){
            move5();
        }
        else{
            clearInterval(s5);
        }
        if(nums==6){
            move6();
        }
        else{
            clearInterval(s6);
        }
    }
  }
  function move_timer1(){
    move_timer_pd(1);
  }
  function move_timer2(){
    move_timer_pd(2);
  }
  function move_timer3(){
    move_timer_pd(3);
  }
  function move_timer4(){
    move_timer_pd(4);
  }
  function move_timer5(){
    move_timer_pd(5);
  }
  function move_timer6(){
    move_timer_pd(6);
  }
  s1 = setInterval(move_timer1,timer);
  s2 = setInterval(move_timer2,timer);
  s3 = setInterval(move_timer3,timer);
  s4 = setInterval(move_timer4,timer);
  s5 = setInterval(move_timer5,timer);
  s6 = setInterval(move_timer6,timer);
  function stopp(obj){
    $(obj).hover(function(){
      if(play1){
        clearInterval(s1);
        play1 = 0;
      }	
      if(play2){
        clearInterval(s2);
        play2 = 0;
      }  
      if(play3){
        clearInterval(s3);
        play3 = 0;
      } 
      if(play4){
        clearInterval(s4);
        play4 = 0;
      }  
      if(play5){
        clearInterval(s5);
        play5 = 0;
      } 
      if(play6){
        clearInterval(s6);
        play6 = 0;
      } 
    },
    function(){
      if(!play1){
        s1 = setInterval(move_timer1,timer); 
        play1 = 1;
      }	
      if(!play2){
        s2 = setInterval(move_timer2,timer); 
        play2 = 1;
      }	
      if(!play3){
        s3 = setInterval(move_timer3,timer); 
        play3 = 1;
      }	
      if(!play4){
        s4 = setInterval(move_timer4,timer); 
        play4 = 1;
      }
      if(!play5){
        s5 = setInterval(move_timer5,timer); 
        play5 = 1;
      }	
      if(!play6){
        s6 = setInterval(move_timer6,timer); 
        play6 = 1;
      }	
    }		  
  );
}
stopp(".banner_show");
$("#banner_show1 .banner_btn_right").click(function(){
  move1(); 
});
$("#banner_hide2 .banner_btn_right").click(function(){
  move2();
});
$("#banner_hide3 .banner_btn_right").click(function(){
  move3();
});
$("#banner_hide4 .banner_btn_right").click(function(){
  move4();
});
$("#banner_hide5 .banner_btn_right").click(function(){
  move5();
});
$("#banner_hide6 .banner_btn_right").click(function(){
  move6();
});
$("#banner_show1 .banner_btn_left").click(function(){
    if(size1>1){
      b1--;
      if(b1<0){
        b1=size1-1
      }
      inbox1.each(function(e){
        inbox1.eq(e).hide(0);
        movelist1.find("a").eq(e).removeClass("hover");
        if(e == b1){
          inbox1.eq(b1).fadeIn(showtime);
          movelist1.find("a").eq(b1).addClass("hover");
        }
       }); 
   }
});
$("#banner_hide2 .banner_btn_left").click(function(){
    if(size2>1){
      b2--;
      if(b2<0){
        b2=size2-1
      }
      inbox2.each(function(e){
        inbox2.eq(e).hide(0);
        movelist2.find("a").eq(e).removeClass("hover");
        if(e == b2){
          inbox2.eq(b2).fadeIn(showtime);
          movelist2.find("a").eq(b2).addClass("hover");
        }
       });
  } 
});
$("#banner_hide3 .banner_btn_left").click(function(){
    if(size3>1){
      b3--;
      if(b3<0){
        b3=size3-1
      }  
       inbox3.each(function(e){
        inbox3.eq(e).hide(0);
        movelist3.find("a").eq(e).removeClass("hover");
        if(e == b3){
          inbox3.eq(b3).fadeIn(showtime);
          movelist3.find("a").eq(b3).addClass("hover");
        }
       });
   } 
});
$("#banner_hide4 .banner_btn_left").click(function(){
  if(size4>1){
      b4--;
      if(b4<0){
        b4=size4-1
      }  
       inbox4.each(function(e){
        inbox4.eq(e).hide(0);
        movelist4.find("a").eq(e).removeClass("hover");
        if(e == b4){
          inbox4.eq(b4).fadeIn(showtime);
          movelist4.find("a").eq(b4).addClass("hover");
        }
       });
   } 
});
$("#banner_hide5 .banner_btn_left").click(function(){
    if(size5>1){
      b5--;
      if(b5<0){
        b5=size5-1
      }  
       inbox5.each(function(e){
        inbox5.eq(e).hide(0);
        movelist5.find("a").eq(e).removeClass("hover");
        if(e == b5){
          inbox5.eq(b5).fadeIn(showtime);
          movelist5.find("a").eq(b5).addClass("hover");
        }
       });
   } 
});
$("#banner_hide6 .banner_btn_left").click(function(){
    if(size6>1){
      b6--;
      if(b6<0){
        b6=size6-1
      }  
       inbox6.each(function(e){
        inbox6.eq(e).hide(0);
        movelist6.find("a").eq(e).removeClass("hover");
        if(e == b6){
          inbox6.eq(b6).fadeIn(showtime);
          movelist6.find("a").eq(b6).addClass("hover");
        }
       }); 
   }
});
movelist1.find("a").click(function(){
  var rel = $(this).attr("rel");
  inbox1.each(function(e){
    inbox1.eq(e).hide(0);
    movelist1.find("a").eq(e).removeClass("hover");
    $("#banner_show1 #banner_magbox1"+e).hide(0);
    if(e == rel){
      inbox1.eq(rel).fadeIn(showtime);
      movelist1.find("a").eq(rel).addClass("hover");
      $("#banner_show1 #banner_magbox1"+rel).show(0);	
    }
  });
});
movelist2.find("a").click(function(){
  var rel = $(this).attr("rel");
  inbox2.each(function(e){
    inbox2.eq(e).hide(0);
    movelist2.find("a").eq(e).removeClass("hover");
    $("#banner_hide2 #banner_magbox2"+e).hide(0);
    if(e == rel){
      inbox2.eq(rel).fadeIn(showtime);
      movelist2.find("a").eq(rel).addClass("hover");
      $("#banner_hide2 #banner_magbox2"+rel).show(0);	
    }
  });
});
movelist3.find("a").click(function(){
  var rel = $(this).attr("rel");
  inbox3.each(function(e){
    inbox3.eq(e).hide(0);
    movelist3.find("a").eq(e).removeClass("hover");
    $("#banner_hide3 #banner_magbox3"+e).hide(0);
    if(e == rel){
      inbox3.eq(rel).fadeIn(showtime);
      movelist3.find("a").eq(rel).addClass("hover");
      $("#banner_hide3 #banner_magbox3"+rel).show(0);	
    }
  });
});
movelist4.find("a").click(function(){
  var rel = $(this).attr("rel");
  inbox4.each(function(e){
    inbox4.eq(e).hide(0);
    movelist4.find("a").eq(e).removeClass("hover");
    $("#banner_hide4 #banner_magbox4"+e).hide(0);
    if(e == rel){
      inbox4.eq(rel).fadeIn(showtime);
      movelist4.find("a").eq(rel).addClass("hover");
      $("#banner_hide4 #banner_magbox4"+rel).show(0);	
    }
  });
});
movelist5.find("a").click(function(){
  var rel = $(this).attr("rel");
  inbox5.each(function(e){
    inbox5.eq(e).hide(0);
    movelist5.find("a").eq(e).removeClass("hover");
    $("#banner_hide5 #banner_magbox5"+e).hide(0);
    if(e == rel){
      inbox5.eq(rel).fadeIn(showtime);
      movelist5.find("a").eq(rel).addClass("hover");
      $("#banner_hide5 #banner_magbox5"+rel).show(0);	
    }
  });
});
movelist6.find("a").click(function(){
  var rel = $(this).attr("rel");
  inbox6.each(function(e){
    inbox6.eq(e).hide(0);
    movelist6.find("a").eq(e).removeClass("hover");
    $("#banner_hide6 #banner_magbox6"+e).hide(0);
    if(e == rel){
      inbox6.eq(rel).fadeIn(showtime);
      movelist6.find("a").eq(rel).addClass("hover");
      $("#banner_hide6 #banner_magbox6"+rel).show(0);	
    }
  });
});
$(".bannger_inbox").each(function(e){
  var inboxsize = $(".bannger_inbox").size();
  inboxwimg = $(this).find("img").width();
//$(".bannger_inbox").eq(e).css({"margin-left":(-1)*inboxwimg/2+"px","z-index":inboxsize-e});
});

});

